package org.pliers.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.time.LocalDateTime;
import java.time.ZoneOffset;


public class    DateMetaObjectHandler implements MetaObjectHandler {

    private String createTimeField = "createTime";
    private String updateTimeField = "updateTime";

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, createTimeField, Long.class, LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
        this.strictInsertFill(metaObject, updateTimeField, Long.class, LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, updateTimeField, Long.class, LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
    }
}